package com.hbue.service.impl;

import com.hbue.bean.User;
import com.hbue.dao.MemberDao;
import com.hbue.dao.impl.MemberDaoImpl;
import com.hbue.service.MemberService;

import java.util.ArrayList;

public class MemberServiceImpl implements MemberService {

    private MemberDao memberDao = new MemberDaoImpl();

    @Override
    public boolean adminLogin(String username, String password) {
        boolean result = memberDao.findById(username,password);
        return result;
    }

    @Override
    public User userLogin(String username, String password) {
       User user =  memberDao.findUser(username,password);
       return user;
    }

    @Override
    public ArrayList<User> findAllUser() {
        ArrayList<User> users =  memberDao.findAll();
        return users;
    }

    @Override
    public void deleteUser(String id) {
        memberDao.deleteById(id);
    }

    @Override
    public User findUser(String id) {
        return memberDao.findUserById(id);
    }

    @Override
    public void updateUser(User user) {
        memberDao.update(user);
    }

    @Override
    public void addUser(User user) {
        memberDao.addUser(user);
    }

    @Override
    public ArrayList<User> searchUser(String searchContent) {
        ArrayList<User> users = memberDao.findUserByIdAndUsername(searchContent);
        return  users;
    }

}
